#include "y2kMain.h"


y2kMain::y2kMain( void )
{
	m_framework = 0;
	m_dx9 = 0;
}


y2kMain::~y2kMain( void )
{	
	clear();
}


void y2kMain::clear( void )
{
	if( m_dx9 )
	{
		delete m_dx9;
		m_dx9 = 0;
	}

	if( m_framework )
	{
		delete m_framework;
		m_framework = 0;
	}
}


bool y2kMain::create( HINSTANCE hInst, WNDPROC winproc )
{
	if( m_framework = new app::GMFramework( hInst, winproc ) )
	{
		m_dx9 = new GMDirectx9( m_framework->windows()->hWnd() );

		return true;
	}

	return false;
}


void y2kMain::initialize( void )
{	
}


void y2kMain::update( void )
{
}


void y2kMain::render( void )
{
	if( m_dx9->check_renderer() )
	{
		if( m_dx9->begin_scene( D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xFFE7E7E7, 1.f, 0 ) )
		{
			m_dx9->end_scene();
		}
	}	
}


long y2kMain::run_message( unsigned int unMessage, WPARAM wParam, LPARAM lParam )
{
	switch( unMessage )
	{
	case WM_KEYDOWN :
		{
			switch( wParam )
			{
			case VK_ESCAPE :
				{
					m_framework->windows()->destroy_windows();
				}
				break;
			}
		}
		return 1;
	}

	return 0;
}